package edu.cuit.zhuyimeng.framework.common.interceptor;

import cn.dev33.satoken.same.SaSameUtil;
import cn.dev33.satoken.stp.StpUtil;
import edu.cuit.zhuyimeng.framework.common.security.UserContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * Feign请求拦截器
 */
public class TokenRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        //添加用户信息
        requestTemplate.header(StpUtil.getTokenName(), UserContext.getToken());
        //添加Same-Token信息
        requestTemplate.header(SaSameUtil.SAME_TOKEN, SaSameUtil.getToken());
    }

}
